package com.uzai.console.web.wechatwork;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.enums.WxqBlacklistTypeEnum;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.wechatwork.wxq.wxgorupblacklist.blacklistprv.WxqWorkBlacklistPrvIdDto;
import com.uzai.console.dto.wechatwork.wxq.wxgorupblacklist.blacklistprv.WxqWorkBlacklistPrvQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.wechatwork.WxqWorkBlacklistPrvService;
import com.uzai.console.vo.base.SelectKeyVo;
import com.uzai.console.vo.wechatwork.wxq.wxgroupblacklist.blacklistprv.WxqWorkBlacklistPrvVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 社群私有黑名单
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "社群私有黑名单",tags = "企业微信|社群黑名单|社群私有黑名单")
@ApiSort(6)
@RestController
public class WxqWorkBlacklistPrvController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(WxqWorkBlacklistPrvController.class);

    @Autowired
    private WxqWorkBlacklistPrvService wxqWorkBlacklistPrvService;

    @ApiOperation(value = "分页查询社群私有黑名单列表", notes = "分页查询社群私有黑名单列表", response = WxqWorkBlacklistPrvVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/wxqWorkBlacklistPrv/findWxqWorkBlacklistPrvList")
    public Object findWxqWorkBlacklistPrvList(@RequestBody WxqWorkBlacklistPrvQuery wxqWorkBlacklistPrvQuery){
        return wxqWorkBlacklistPrvService.findWxqWorkBlacklistPrvList(wxqWorkBlacklistPrvQuery);
    }

    @SystemLogType(model = SystemModelEnum.WxqWorkBlacklistPrv, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "移除社群私有黑名单", notes = "移除社群私有黑名单")
    @ApiOperationSupport(order = 4)
    @PostMapping("/wxqWorkBlacklistPrv/deleteWxqWorkBlacklistPrv")
    public Object deleteWxqWorkBlacklistPrv(@RequestBody WxqWorkBlacklistPrvIdDto wxqWorkBlacklistPrvIdDto){
        wxqWorkBlacklistPrvService.deleteWxqWorkBlacklistPrv(wxqWorkBlacklistPrvIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.WxqWorkBlacklistPrv, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "共享至全网", notes = "共享至全网")
    @ApiOperationSupport(order = 5)
    @PostMapping("/wxqWorkBlacklistPrv/shareWxqWorkBlacklistPub")
    public Object shareWxqWorkBlacklistPub(@RequestBody WxqWorkBlacklistPrvIdDto wxqWorkBlacklistPrvIdDto){
        wxqWorkBlacklistPrvService.shareWxqWorkBlacklistPub(wxqWorkBlacklistPrvIdDto);
        return true;
    }

    @ApiOperation(value = "查询社群黑名单类型下拉选择框列表", notes = "查询社群黑名单类型下拉选择框列表")
    @ApiOperationSupport(order = 7)
    @PostMapping("/wxqWorkBlacklistPrv/findWxqWorkBlacklistTypeSelect")
    public Object findWxqWorkBlacklistTypeSelect(){
        List<SelectKeyVo> selectIdVoList = new ArrayList<>();
        for (WxqBlacklistTypeEnum wxqWorkBlacklistTypeEnum : WxqBlacklistTypeEnum.values()){
            SelectKeyVo selectKeyVo = new SelectKeyVo();
            selectKeyVo.setKey(String.valueOf(wxqWorkBlacklistTypeEnum.getValue()));
            selectKeyVo.setValue(wxqWorkBlacklistTypeEnum.getDesc());
            selectIdVoList.add(selectKeyVo);
        }
        return selectIdVoList;
    }

    @SystemLogType(model = SystemModelEnum.WxqWorkBlacklistPrv, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "取消共享至全网", notes = "取消共享至全网")
    @ApiOperationSupport(order = 8)
    @PostMapping("/wxqWorkBlacklistPrv/cancleWxqWorkBlacklistPub")
    public Object cancleWxqWorkBlacklistPub(@RequestBody WxqWorkBlacklistPrvIdDto wxqWorkBlacklistPrvIdDto){
        wxqWorkBlacklistPrvService.cancelWxqWorkBlacklistPub(wxqWorkBlacklistPrvIdDto);
        return true;
    }

}
